// pages/smrz/smrz.js
var a = getApp();
Page({

  data: {
    face_card: '../image/zheng.jpg',
    smit_card: '../image/fan.jpg',
    is_valid: 0,

  },
  addImg: function (e) {
    var t = this;
    a.upimgs({
      scannums: 1,
      filename: "cars",
      success: function (a) {
        t.setData({
          face_card: a[0].all
      
        });
      }
    });
  },
  addImgTwo: function (e) {
    var t = this;
    a.upimgs({
      scannums: 1,
      filename: "logo",
      success: function (a) {
    
        t.setData({
          smit_card: a[0].all
        });
      }
    });
  },
  fromsubmit: function (e) {
 
    var t = this;
    console.log(t.data.face_card)
    if (t.data.face_card == '../image/zheng.jpg' || t.data.smit_card == '../image/fan.jpg'){
      wx.showModal({
        title: "请上传照片",
        showCancel: !1,
      })
    }else{
      a.util.request({
        url: "entry/wxapp/Api",
        data: {
          m: "monai_market",
          r: "extends.idcardinfo",
          uid: wx.getStorageSync("uid"),
          nickname: e.detail.value.nickname,
          face_card: t.data.face_card,
          smit_card: t.data.smit_card
        },
        success: function (aa) {
          console.log(aa)
          t.setData({
            is_valid: 1
          })
          wx.showToast({
            title: "提交成功",
            icon: "success",
            duration: 2e3,
            complete: function (e) {
              console.log(e)
              wx.switchTab({
                url: '../mine/index'
              })
            }
          });
        }
      });
    }
    
  },
  onLoad: function(e) {
    var that =this
    console.log('dddd',e)
    if (e.face_card != 'undefined' || e.smit_card !='undefined'){
      that.setData({
        is_valid: e.is_valid,
        face_card: e.face_card,
        smit_card: e.smit_card
      })
    }else{
      that.setData({
        face_card: '../image/zheng.jpg',
        smit_card: '../image/fan.jpg',
      })
    }
    
    // that.data.is_valid = a.globalData.is_valid
    console.log('1',a.globalData.is_valid)
    console.log('2',that.data)
  },
})